<?php
class SP_Database_BaseRecord
{
	protected $table_name;
	protected $base;
	
	function __construct($base)
	{
		$this->base = clone $base;
	}
	
	protected function setTableName($name)
	{
		$this->table_name=$name;
	}
	
	public function getTableName()
	{
		return $this->table_name;
	}
	
	public function readWhere($where)
	{
		$this->fromRow($this->base->getAssocRow("SELECT * FROM `".$this->table_name."` WHERE $where LIMIT 1"));
		return (bool)$this->base->getResult();
	}
	
	public function readById($id)
	{
		if (!SP_Helpers_Checker::checkID($id)) return false;
		$this->fromRow($this->base->getAssocRow("SELECT * FROM `".$this->table_name."` WHERE id='$id' LIMIT 1"));
		return (bool)$this->base->getResult();
	}
	
}